﻿FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["Admin/Admin.WebApi/Admin.WebApi.csproj", "Admin/Admin.WebApi/"]
COPY ["Swimj/Swimj.AspNetCore/Swimj.AspNetCore.csproj", "Swimj/Swimj.AspNetCore/"]
COPY ["Swimj/Swimj.CommonLib/Swimj.CommonLib.csproj", "Swimj/Swimj.CommonLib/"]
COPY ["Swimj/Swimj.Core/Swimj.Core.csproj", "Swimj/Swimj.Core/"]
COPY ["Admin/Admin.ApplicationLib/Admin.ApplicationLib.csproj", "Admin/Admin.ApplicationLib/"]
COPY ["Swimj/Swimj.DataCore/Swimj.DataCore.csproj", "Swimj/Swimj.DataCore/"]
COPY ["Admin/Admin.CommonLib/Admin.CommonLib.csproj", "Admin/Admin.CommonLib/"]
RUN dotnet restore "Admin/Admin.WebApi/Admin.WebApi.csproj"
COPY . .
WORKDIR "/src/Admin/Admin.WebApi"
RUN dotnet build "Admin.WebApi.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Admin.WebApi.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Admin.WebApi.dll"]
